package com.example.xingxing.mobilesafe.activity;

import android.app.Activity;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.View;

import com.example.xingxing.mobilesafe.R;
import com.example.xingxing.mobilesafe.utils.PreferenceUtil;
import com.example.xingxing.mobilesafe.view.SettingItemView;

public class SettingActivity extends Activity {

    private SettingItemView updateCell;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_setting);

        updateCell = (SettingItemView) findViewById(R.id.update_setting_item);
        boolean autoUpdate = PreferenceUtil.getBoolean("auto_update", true, getApplicationContext());
        updateCell.setChecked(autoUpdate);

        updateCell.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                updateCell.setChecked(!updateCell.isChecked());
                PreferenceUtil.putBoolean("auto_update", !updateCell.isChecked(), getApplicationContext());
            }
        });
    }
}
